package edu.sdjzu.exam.mapper;


import edu.sdjzu.exam.domain.question.QuestionOption;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface QuestionOptionsMapper {

    @Insert("INSERT INTO Question_Options (question_id, content, is_correct, option_order) " +
            "VALUES (#{questionId}, #{content}, #{isCorrect}, #{optionOrder})")
    void insertOption(QuestionOption option);

    @Select("SELECT * FROM Question_Options WHERE question_id = #{questionId}")
    List<QuestionOption> selectOptionsByQuestionId(Long questionId);

    @Update("UPDATE Question_Options SET content = #{content}, is_correct = #{isCorrect}, " +
            "option_order = #{optionOrder} WHERE option_id = #{optionId}")
    void updateOption(QuestionOption option);

    @Delete("DELETE FROM Question_Options WHERE option_id = #{optionId}")
    void deleteOption(Long optionId);

    @Delete("DELETE FROM Question_Options WHERE question_id = #{questionId}")
    void deleteOptionsByQuestionId(Long questionId);
}
